/**
 * @author 雷明浩
 * @date 2025/6/3 16:31
 */
public class Find {
    // newcoder 二维数组中的查找
    // https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page
    public boolean Find (int target, int[][] array) {
        // write code here
        int m = array.length, n = array[0].length;
        int x = 0, y = n-1;
        while (x < m && y >= 0) {
            if (array[x][y] == target) {
                return true;
            }else if (array[x][y] > target) {
                y--;
            }else if (array[x][y] < target) {
                x++;
            }
        }
        return false;
    }
}